from multiprocessing import Pool
import os,time
def long_time_task(name):
    print("name:{},PID:{}".format(name,os.getpid()))
    start = time.time()
    time.sleep(random.random()*3)
    end = time.time()
    print('Task{} runs time:{}'.format(name,self.getpid()))
if __name__ == '__main__':
    print('Parent process PID:{}'.format(os.getpid()))
    p = Pool(4)
    for i in range(9):
        p.apply_async(long_time_task,args=(i,))
    print('Waiting for all subprocesss done...')
    p.close()
    p.join()
    print('All subprocesses done.')

